package com.sixth.docker.service.impl;

import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sixth.core.entity.Medicines;
import com.sixth.core.vo.R;
import com.sixth.docker.mapper.MedicinesMapper;
import com.sixth.docker.service.MedicinesService;
import com.sixth.docker.vo.MedicinesVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: sixth-hospital-parent
 * @description:
 * @author: 赵庆龙
 * @create: 2024-08-20 09:54
 **/
@Service
public class MedicinesServiceImpl implements MedicinesService {
    @Autowired
    private MedicinesMapper medicinesMapper;

    @Override
    public R<IPage<Medicines>> selectByPage(MedicinesVo medicinesVo) {
       IPage<Medicines> page = new Page<>(medicinesVo.getPageNum(), medicinesVo.getPageSize());
       QueryWrapper<Medicines> wrapper = new QueryWrapper<>();
       if (medicinesVo.getKeywords() != null && !medicinesVo.getKeywords().trim().isEmpty()) {
           wrapper.like("keywords", medicinesVo.getKeywords().trim());
       }
       wrapper.eq("status", "0");
       IPage<Medicines> medicinesIPage = medicinesMapper.selectPage(page, wrapper);
       return R.ok(medicinesIPage);
    }
}
